local ty_1v2_wc = fk.CreateSkill {
    name = "ty_1v2_wc&",
    tags = { Skill.Limited }
}

Fk:loadTranslationTable {
    ["ty_1v2_wc&"] = "宛城",
    [":ty_1v2_wc&"] = "限定技，出牌阶段结束时，你可以对一名角色使用所有伤害牌，此技能结算后若其没有死亡，你废除所有装备栏。",
}

ty_1v2_wc:addEffect(fk.EventPhaseEnd, {
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(ty_1v2_wc.name) and player.phase == Player.Play and
            player:usedSkillTimes(ty_1v2_wc.name, Player.HistoryGame) == 0 and not player:isKongcheng()
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local to = room:askToChoosePlayers(player, {
            targets = room:getOtherPlayers(player, false),
            min_num = 1,
            max_num = 1,
            prompt = "宛城：你可以选择一名角色，对其依次使用手中的伤害牌",
            skill_name = ty_1v2_wc.name,
            cancelable = true,
        })
        if #to > 0 then
            event:setCostData(self, { tos = to })
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local to = event:getCostData(self).tos[1]
        local ids = table.filter(player:getCardIds("h"), function(id)
            return Fk:getCardById(id).is_damage_card
        end)
        if #ids == 0 then return end
        while not player.dead and not to.dead do
            if to.dead then break end
            local id = room:askToCards(player, {
                min_num = 1,
                max_num = 1,
                pattern = tostring(Exppattern { id = ids }),
                prompt = "宛城：请选择要使用的牌，目标为::" .. to.id,
                skill_name = "ty_1v2_wc",
                cancelable = true,
            })[1]
            local card = Fk:getCardById(id)
            if card and player:canUseTo(card, to, { bypass_distances = true, bypass_times = true }) then
                local use = {
                    from = player,
                    tos = { to },
                    card = card,
                    extra_data = {
                        que_gangkai_use = player,
                    }
                }
                room:useCard(use)
            else
                break
            end
        end
        if not to.dead then
            local slots = player:getAvailableEquipSlots()
            if #slots > 0 then
                room:abortPlayerArea(player, slots)
            end
        end
    end,
})
return ty_1v2_wc
